package com.briup.jd2407cms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.briup.jd2407cms.domain.Slideshow;
import com.briup.jd2407cms.result.Result;
import com.briup.jd2407cms.service.SlideshowService;
import com.briup.jd2407cms.mapper.SlideshowMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 李国强
* @description 针对表【cms_slideshow】的数据库操作Service实现
* @createDate 2024-11-18 14:40:02
*/
@Service
public class SlideshowServiceImpl extends ServiceImpl<SlideshowMapper, Slideshow>
    implements SlideshowService{
    @Autowired
    SlideshowMapper slideshowMapper;

//    public List<Slideshow> getAllByPage(Integer pageSize,Integer pageNum,String status,String description){
//        IPage<Slideshow> page = new Page<>(pageNum,pageSize);
//        System.out.println(2);
//        if(status!=null&&!"".equals(status)){
//            LambdaQueryWrapper<Slideshow> lqw = new LambdaQueryWrapper<Slideshow>();
//            lqw.eq(Slideshow::getStatus, lqw);
//            lqw.orderByDesc(Slideshow::getUploadTime);
//            IPage iPage = slideshowMapper.selectPage(page, lqw);
//            return iPage.getRecords();
//        }
//        if (description!=null&&!"".equals(description)){
//            LambdaQueryWrapper<Slideshow> lqw = new LambdaQueryWrapper<Slideshow>();
//            lqw.eq(Slideshow::getDescription, lqw);
//            lqw.orderByDesc(Slideshow::getUploadTime);
//            IPage iPage = slideshowMapper.selectPage(page, lqw);
//            return iPage.getRecords();
//        }
//        LambdaQueryWrapper<Slideshow> lqw = new LambdaQueryWrapper<Slideshow>();
//        lqw.orderByDesc(Slideshow::getUploadTime);
//        System.out.println(1);
//        IPage iPage = slideshowMapper.selectPage(page, lqw);
//        System.out.println("页码："+iPage);
//        return iPage.getRecords();
//    }
    public List<Slideshow> getAllByPage(Integer pageSize,Integer pageNum,String status,String description){
        Page<Slideshow> objectPage = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<Slideshow> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
        objectLambdaQueryWrapper.like(description!=null,Slideshow::getDescription,description)
                .eq(status!=null,Slideshow::getStatus,status);
        return slideshowMapper.selectPage(objectPage,objectLambdaQueryWrapper).getRecords();
    }
}




